package com.zh.ssmshirofreemarker.controller;

import com.zh.ssmshirofreemarker.Utils.ResponseUtil;
import com.zh.ssmshirofreemarker.entity.User;
import com.zh.ssmshirofreemarker.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@RequestMapping("/register")
@Controller
public class RegisterController {


    @Autowired
    IUserService userService;

    @RequestMapping(method = RequestMethod.GET)
    public String init(){
        return "register";
    }

    @ResponseBody
    @RequestMapping(method = RequestMethod.POST)
    public ResponseUtil doRegister(User user){
       return userService.addUser(user);
    }

}
